package hn.sigit.interop.ws;

import hn.sigit.recyclebin.TransactionStatesXMLProducer;

import java.io.ByteArrayOutputStream;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;


//@Stateless
//@WebContext(contextRoot="/sigit-services", urlPattern="/transaction")
@SOAPBinding(style=SOAPBinding.Style.RPC)
@WebService(targetNamespace="http://ws.sigit.hn/")
public class SigitTransactionWS {

	public SigitTransactionWS() {
	}
	
	
	private String getStateTransaction(Long presentationId, boolean beforeTransaction) {
		TransactionStatesXMLProducer xmlProducer = new TransactionStatesXMLProducer();
		
		xmlProducer.setBeforeTransaction(beforeTransaction);
		xmlProducer.setPresentationId(presentationId);
		
		ByteArrayOutputStream baos = new ByteArrayOutputStream(16834);
		
		xmlProducer.produceXml(baos);
		
		return baos.toString();
	}
	
	
	@WebMethod
	public String getStateBeforeTransaction(Long presentationId) {
		return getStateTransaction(presentationId, true);
	}
	
	@WebMethod
	public String getStateAfterTransaction(Long presentationId) {
		return getStateTransaction(presentationId, false);
	}

	
}
